// pages/safe/safe.js
Page({
    data:{
        user:{
            useId:'1',
            telNum:'123'
        }
    },
    queryUser(){
        var that = this; 
        var app = getApp();
        that.data.user.useId = app.data.useId;
        wx.request({
            url: 'http://localhost:8080/user/search?userId='+that.data.user.useId,
            method:'GET',
            header:{
                'content-type':'application/json'
            },
            success:function(res){
                console.log(res);
                that.setData({
                    user:res.data.data
                })
                console.log(that.data.user)
            }
        })
    },
    deleteUser(){
        var that = this; 
        var app = getApp();
        that.data.user.useId = app.data.useId;
        wx.request({
            url: 'http://localhost:8080/user/delUser?useId='+that.data.user.useId,
            method:'GET',
            header:{
                'content-type':'application/json'
            },
            success:function(res){
                wx.showModal({
                  title: '提示',
                  content: '是否要注销账号？',
                  complete: (res) => {
                    if (res.cancel) {
                      
                    }
                
                    if (res.confirm) {
                        wx.reLaunch({
                          url: '/pages/login/login',
                        })
                    }
                  }
                })
            }
        })
    },
    onShow(){
        this.queryUser();
    }

})